<template>
    <div class="app-container customer-div">
<!--        <el-button-group>-->
<!--          <el-button type="primary">排货列表</el-button>-->
<!--          <el-button @click="topurchasePickUp">采购提货</el-button>-->
<!--        </el-button-group>-->
        <el-menu :default-active="listQuery.planState" class="el-menu-demo" mode="horizontal" @select="handleSelect">
            <el-menu-item index="">全部</el-menu-item>
            <el-menu-item index="0">待物流发货</el-menu-item>
            <el-menu-item index="10">发货中</el-menu-item>
            <el-menu-item index="20">待安排司机</el-menu-item>
            <el-menu-item index="30">待出库</el-menu-item>
            <el-menu-item index="40">已出库</el-menu-item>
            <el-menu-item index="5">已取消</el-menu-item>
            <el-menu-item index="50">提货待物流确认({{waitNum}})</el-menu-item>
            <el-menu-item index="60">全部提货</el-menu-item>
        </el-menu>
        <div style="margin-top: 40px">
            <!--搜索-->
            <el-form :inline="true" :model="listQuery" size="mini" label-width="100px">
                <el-form-item label="订单号：" >
                    <el-input v-model="listQuery.orderSn"></el-input>
                </el-form-item>
                <el-form-item label="客户编号：">
                  <el-input v-model="listQuery.customerNumber"></el-input>
<!--                    <el-autocomplete-->
<!--                            clearable-->
<!--                            class="inline-input"-->
<!--                            value-key="customerName"-->
<!--                            :fetch-suggestions="querySearch"-->
<!--                            v-model="listQuery.customerName"-->
<!--                            placeholder="请输入内容"-->
<!--                            @select="handleSelectCustomerName"-->
<!--                            :trigger-on-focus="false"-->
<!--                    ></el-autocomplete>-->
                </el-form-item>
                <el-form-item label="业务员：">
                    <el-select v-model="listQuery.orderUserId" filterable placeholder="请选择" clearable>
                        <el-option
                                v-for="item in userOptionList"
                                :key="item.userId"
                                :label="item.userName"
                                :value="item.userId">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="交易方式：" >
                    <el-select v-model="listQuery.deliveryType" filterable placeholder="请选择" clearable>
                        <el-option
                                key="供方送到需方仓库"
                                label="供方送到需方仓库"
                                value="供方送到需方仓库">
                        </el-option>
                        <el-option
                                key="需方在供方仓库自提"
                                label="需方在供方仓库自提"
                                value="需方在供方仓库自提">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="发货类型：" >
                    <el-select v-model="listQuery.sendType" filterable placeholder="请选择" clearable>
                        <el-option
                                key="公司发货"
                                label="公司发货"
                                value="公司发货">
                        </el-option>
                        <el-option
                                key="采购发货"
                                label="采购发货"
                                value="采购发货">
                        </el-option>
                        <el-option
                                key="客户自提"
                                label="客户自提"
                                value="客户自提">
                        </el-option>
                    </el-select>
                </el-form-item>
<!--                <el-form-item label="送货类型：" >-->
<!--                    <el-select v-model="listQuery.isYunlianDeliver" filterable placeholder="请选择" clearable>-->
<!--                        <el-option-->
<!--                                :key="1"-->
<!--                                label="运联发货"-->
<!--                                :value="1">-->
<!--                        </el-option>-->
<!--                        <el-option-->
<!--                                :key="0"-->
<!--                                label="采购发货"-->
<!--                                :value="0">-->
<!--                        </el-option>-->
<!--                    </el-select>-->
<!--                </el-form-item>-->
                <el-form-item label="商品信息">
                    <el-input v-model="listQuery.goodsKeyword"></el-input>
                </el-form-item>
                <el-form-item label="提货日期：">
                    <el-date-picker
                            :default-time="['00:00:00', '23:59:59']"
                            v-model="listQuery.date"
                            type="daterange"
                            format="yyyy 年 MM 月 dd 日"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="发货状态：" >
                    <el-select v-model="listQuery.planGoodsState" filterable placeholder="请选择" clearable>
                        <el-option key="0" label="未发货" value="0"></el-option>
                        <el-option key="1" label="部分发货" value="1"></el-option>
                        <el-option key="2" label="已发货" value="2"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button
                            @click="handleSearchList()"
                            type="primary">
                        查询
                    </el-button>
                </el-form-item>
            </el-form>
        </div>
        <!--数据列表-->
        <div class="table-container">
            <el-table :header-cell-style="{'text-align':'center'}" tooltip-effect="light" v-loading="listLoading" :data="tableData" border style="width: 100%; margin-top: 20px">
                <el-table-column  label="销售单号" width="150" align="center" prop="orderSn" fixed="left"></el-table-column>
                <el-table-column  label="客户编号" width="100" fixed="left">
                    <template slot-scope="scope">
                      <span>
                        {{scope.row.customerNumber }}
                      </span>
                      <!--是否有权限-->
                      <div v-if="scope.row.isShowCustomerName">{{scope.row.customerName}}</div>
                    </template>
                </el-table-column>
                <el-table-column  label="商品信息" width="100" fixed="left">
                    <template slot-scope="scope">
                        {{scope.row.goodsName}} / {{scope.row.goodsSn}} / {{scope.row.goodsNum}}吨
                    </template>
                </el-table-column>

              <el-table-column  label="商品备注" width="100" fixed="left">
                <template slot-scope="scope">
                    {{scope.row.goodsRemark}}
                </template>
              </el-table-column>

                <el-table-column  label="采购合同号" width="150" align="center">
                    <template slot-scope="scope">
                        {{scope.row.purchaseSn}}
                    </template>
                </el-table-column>

                <el-table-column  label="收货信息" width="150" fixed="left">
                    <template slot-scope="scope">
                       <div> {{ scope.row.receiverName}} <span style="padding-left:15px">{{scope.row.receiverMobile}}</span></div>
                       <div>{{scope.row.addressInfo}}</div>
                    </template>
                </el-table-column>

                <el-table-column  label="提货类型" width="100" align="center" fixed="left">
                  <template slot-scope="scope">
                      {{scope.row.planSendType}}
                  </template>
                </el-table-column>

                <el-table-column align="center" label="发货类型" width="100">
                  <template slot-scope="scope">
                    {{scope.row.sendType}}
                  </template>
                </el-table-column>

                <el-table-column label="提货仓库" width="100" align="center" fixed="left">
                    <template slot-scope="scope">
                        {{scope.row.warehouseName}}
                    </template>
                </el-table-column>

                <el-table-column
                        fixed="left"
                        label="提货地址"
                        width="100">
                    <template slot-scope="scope">
                        {{scope.row.takeAddress}}
                    </template>
                </el-table-column>

                <el-table-column
                       fixed="left"
                        label="提货时间"
                        width="100"
                        align="center">
                    <template slot-scope="scope">
                        {{scope.row.takeTime}}
                    </template>
                </el-table-column>

                <el-table-column
                       fixed="left"
                        label="提货数量"
                        width="80"
                        align="center">
                    <template slot-scope="scope">
                      <span v-if="scope.row.goodsNum != scope.row.takeNum" style="color:Red"> {{scope.row.takeNum}}</span>
                      <span v-else>{{scope.row.takeNum}}</span>
                    </template>
                </el-table-column>

                <el-table-column
                  label="业务员"
                  width="80"
                  align="center">
                  <template slot-scope="scope">
                    {{scope.row.userRealName}}
                  </template>
                </el-table-column>

                <el-table-column
                        show-overflow-tooltip
                        label="提货备注"
                        width="200">
                    <template slot-scope="scope">
                        {{scope.row.takeRemark}}
                    </template>
                </el-table-column>


              <el-table-column
                align="center"
                label="确定能否提货"
                width="80">
                <template slot-scope="scope">
                  {{scope.row.isSure == 1 ? '确定' : '不确定'}}
                </template>
              </el-table-column>

                <el-table-column
                        align="center"
                        label="已发货数量"
                        width="100">
                    <template slot-scope="scope">
                        {{scope.row.actualShipNum}}
                    </template>
                </el-table-column>
                <el-table-column
                        align="center"
                        label="发货状态"
                        width="100">
                    <template slot-scope="scope">
                        {{scope.row.actualShipNum | shipType(scope.row.takeNum)}}
                    </template>
                </el-table-column>

              <el-table-column
                label="司机信息"
                width="200">
                <template slot-scope="scope">
                   <div>{{scope.row.driverName}} {{scope.row.driverMobile}} {{scope.row.driverTruckNo}}</div>
                </template>
              </el-table-column>

              <el-table-column
                align="center"
                label="发货单号"
                width="100">
                <template slot-scope="scope">
                    {{scope.row.deliverSn}}
                </template>
              </el-table-column>


                <el-table-column  label="交易方式" width="150" align="center">
                    <template slot-scope="scope">
                        {{scope.row.deliveryType}}
                    </template>
                </el-table-column>



                <el-table-column
                        label="创建时间"
                        width="150"
                        align="center">
                    <template slot-scope="scope">
                        {{scope.row.createTime}}
                    </template>
                </el-table-column>

              <el-table-column
                label="排货状态"
                width="100"
                align="center">
                <template slot-scope="scope">
                   {{scope.row.planState | fifState}}
                </template>
              </el-table-column>

              <el-table-column
                v-if="listQuery.planState=='5'"
                label="取消类型"
                width="100"
                align="center">
                <template slot-scope="scope">
                  {{scope.row.cancelType }}
                </template>
              </el-table-column>

              <el-table-column
                v-if="listQuery.planState=='5'"
                label="取消原因"
                width="100"
                align="center">
                <template slot-scope="scope">
                  {{scope.row.cancelRemark }}
                </template>
              </el-table-column>
              <el-table-column
                v-if="listQuery.planState=='5'"
                label="损失运费"
                width="100"
                align="center">
                <template slot-scope="scope">
                  {{scope.row.lossFreight }}
                </template>
              </el-table-column>

              <el-table-column
                v-if="listQuery.planState=='5'"
                label="取消时间"
                width="150"
                align="center">
                <template slot-scope="scope">
                  {{scope.row.cancelTime }}
                </template>
              </el-table-column>

                <el-table-column
                  show-overflow-tooltip
                  fixed="right"
                  label="结算方式"
                  width="100"
                  align="center">
                  <template slot-scope="scope">
                    <span style="color:red;cursor: default">{{scope.row.orderRemark}}</span>
                  </template>
                </el-table-column>

                <el-table-column
                        width="100"
                        fixed="right"
                        label="操作"
                        align="center">
                    <template slot-scope="scope">
                          <el-button
                            style="margin-left:0"
                            type="text"
                            size="mini"
                            @click="toInfo(scope.row)">查看详情
                          </el-button>
                           <!--公司发货  物流确认发货 打印提货单  到详情-->
                           <div v-if="scope.row.planSendType == '运联发货'">
                             <el-button
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="showDialog3(scope.row)">提货信息
                             </el-button>
                             <el-button
                               v-if="scope.row.planState == 0"
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="showSendGoods(scope.row)">物流发货
                             </el-button>
                             <el-button
                               v-if="scope.row.planState == 10"
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="showHoYuan(scope.row)">货源信息
                             </el-button>

                             <el-button
                               v-if="scope.row.planState == 10"
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="toInfo(scope.row)">物流确认发货
                             </el-button>

                             <el-button
                               v-if="scope.row.planState == 30"
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="toInfo(scope.row)">打印提货单
                             </el-button>

                             <el-button
                               v-if="scope.row.isNeedCheck == 1 && scope.row.planState == 30"
                               style="margin-left:0"
                               type="text"
                               size="mini"
                               @click="showDialogVisible(scope.row)">确认出库
                             </el-button>

                           </div>
                          <!--采购发货 打印提货单  到详情-->
                          <div v-if="scope.row.planSendType == '工厂发货'">
                            <el-button
                              v-if="scope.row.planState != 5"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="showDialog3(scope.row)">提货信息
                            </el-button>
                            <el-button
                              v-if="scope.row.planState == 20"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="toInfo(scope.row)">填写司机
                            </el-button>
                            <el-button
                              v-if="scope.row.isNeedCheck == 1 && scope.row.planState == 30"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="showDialogVisible(scope.row)">确认出库
                            </el-button>
                            <el-button
                              v-if="scope.row.planState == 30"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="toInfo(scope.row)">打印提货单
                            </el-button>

                          </div>
                          <!--客户自提 填写司机 打印提货单  到详情-->
                          <div v-if="scope.row.planSendType == '自提'">
                            <el-button
                              v-if="scope.row.planState != 5"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="showDialog3(scope.row)">提货信息
                            </el-button>
                            <el-button
                              v-if="scope.row.planState == 20"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="toInfo(scope.row)">填写司机
                            </el-button>
                            <el-button
                              v-if="scope.row.planState == 30"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="toInfo(scope.row)">打印提货单
                            </el-button>
                            <el-button
                              v-if="scope.row.isNeedCheck == 1 && scope.row.planState == 30"
                              style="margin-left:0"
                              type="text"
                              size="mini"
                              @click="showDialogVisible(scope.row)">确认出库
                            </el-button>
                          </div>
                    </template>
                </el-table-column>

            </el-table>
        </div>
        <div class="pagination-container">
            <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    layout="total, sizes,prev, pager, next,jumper"
                    :current-page.sync="listQuery.pageNum"
                    :page-size="listQuery.pageSize"
                    :page-sizes="[10,15,20]"
                    :total="count">
            </el-pagination>
        </div>

        <!--提货信息弹窗-->
        <el-dialog
                :close-on-click-modal="false"
                title="提货信息"
                :visible.sync="dialogVisible3"
                width="400px">
            <el-form size="mini" label-width="90px"  ref="priceForm" >
                <el-form-item label="商品信息：" style="margin-bottom:0px">
                        {{priceForm.goodsName}}
                </el-form-item>
                <el-form-item label="提货仓库：" style="margin-bottom:0px">
                    {{priceForm.warehouseName}}
                </el-form-item>
                <el-form-item label="提货时间：" style="margin-bottom:0px">
                    {{priceForm.takeTime}}
                </el-form-item>
                <el-form-item label="提货地址：" style="margin-bottom:0px">
                    {{priceForm.takeAddress}}
                </el-form-item>
                <el-form-item label="提货数量：" style="margin-bottom:0px">
                    {{priceForm.takeNum}}
                </el-form-item>
                <el-form-item label="联系人：" style="margin-bottom:0px">
                    {{priceForm.contactName}}
                </el-form-item>
                <el-form-item label="手机号：" style="margin-bottom:0px">
                    {{priceForm.contactMobile}}
                </el-form-item>
                <el-form-item label="注意事项：">
                    {{priceForm.takeRemark}}
                </el-form-item>
            </el-form>
        </el-dialog>


        <!--确认出库-->
        <el-dialog
                title="确认出库"
                :visible.sync="dialogVisible2"
                width="800px">
            <div style="max-height:500px;overflow: auto">
                <el-table ref="multipleTable"
                          row-key="dgId"
                          :data="sendList"
                          style="width: 95%;font-size: 12px;margin:0 auto"
                          @selection-change="handleSelectionChange"
                          v-loading="listLoading2"
                          border>
                    <el-table-column type="selection" :reserve-selection="true" width="60" align="center" :selectable="checkSelectable"></el-table-column>
                    <el-table-column label="发货单号" align="center" width="150">
                        <template slot-scope="scope">
                            {{scope.row.deliverSn}}
                        </template>
                    </el-table-column>
                    <el-table-column label="销售单号" align="center" width="150">
                        <template slot-scope="scope">
                            {{scope.row.orderSn}}
                        </template>
                    </el-table-column>
                    <el-table-column label="商品信息" >
                        <template slot-scope="scope">
                            {{scope.row.goodsName}}
                        </template>
                    </el-table-column>
                    <el-table-column label="发货数量" align="center">
                        <template slot-scope="scope">
                            {{scope.row.shipNum}}
                        </template>
                    </el-table-column>
                    <el-table-column label="未核减数量" align="center">
                        <template slot-scope="scope">
                            {{scope.row.unPlanNum}}
                        </template>
                    </el-table-column>
                    <el-table-column label="送货类型" align="center">
                        <template slot-scope="scope">
                            {{scope.row.sendType}}
                        </template>
                    </el-table-column>
                </el-table>
                <div style="width: 95%;font-size: 12px;margin:20px auto 0 auto">
                    <div>需核减数量：<span style="font-size:14px;font-weight: bold">{{PlanNum}}</span> 吨 <span style="padding-left:20px">已选核减数量：<span style="color:#409EFF;font-weight: bold;font-size:14px">{{chooseUnPlanNum}}</span> 吨</span></div>
                    <div style="color:red;font-size:12px;margin-top:10px">说明：如果已选核减数量大于需核减数量，将按照选择的发货单顺序逐一核减，多出的发货数量将不会被核减</div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                  <el-button @click="handleClose2">取 消</el-button>
                  <el-button type="primary" @click="handleConfirm2">确 定</el-button>
            </span>
        </el-dialog>

        <sendGoods ref="sendGoods" @handleConfirm="getList"></sendGoods>

        <!--查看货源-->
        <sourceGoods ref="sourceGoods"></sourceGoods>
    </div>
</template>
<script>
    import {getCustomerOption,getOrderUsersList,getDeliverGoods,planGoodsOperate,takeCount} from '@/api/partner'
    import {getGoodsPlanList,getPlanGoodsList} from '@/api/company'
    import {formatDate} from '@/utils/date';
    import sendGoods from '@/views/components/sendGoods';
    import sourceGoods from '@/views/components/sourceGoods'
    import store from '@/store'
    import { mapGetters } from 'vuex'
    const defaultListQuery={
        pageNum: 1,
        pageSize: 10,
        date: [],
        orderSn:null,
        customerName:null,
        orderUserId:null,
        sendType:'',
        deliveryType:'',
        goodsKeyword:'',
        planGoodsState:null,
        planState:'',
        customerNumber:''
    };
    const defaultPriceForm={
        goodsName: '',
        warehouseName: '',
        takeTime:'',
        takeAddress:'',
        takeNum:'',
        contactName:'',
        contactMobile:'',
        takeRemark:'',
    };
    export default {
        name: "index",
        data(){
            return {
                listQuery: JSON.parse(JSON.stringify(defaultListQuery)),
                tableData: [],
                count: 0,
                listLoading: false,
                roles:store.getters.roles ? store.getters.roles : [],
                userOptionList:[],
                dialogVisible3:false,
                goodsPlanList:[],
                priceForm:JSON.parse(JSON.stringify(defaultPriceForm)),
                dialogVisible2:false,
                sendList:[],
                selectList:[],
                listLoading2:false,
                chooseUnPlanNum:0,//已选核减数量
                PlanNum:0,//需核减数量
                dpgId:'',
                waitNum:''
            }
        },
        computed: {
            ...mapGetters([
                'name',
                'mobile',
                'userId'
            ]),

        },
      components : {
        sendGoods:sendGoods,
        sourceGoods:sourceGoods,
      },
        created() {
            let now = new Date();
            let nowMonth = now.getMonth(); //当前月
            let nowYear = now.getFullYear(); //当前年
            //本月的开始时间
            let monthStartDate = new Date(nowYear, nowMonth, 1);
            //本月的结束时间
            let monthEndDate = new Date(nowYear, nowMonth+1, 0,23,59,59);
            let startDate = formatDate(monthStartDate, 'yyyy-MM-dd hh:mm:ss');
            let endDate = formatDate(monthEndDate, 'yyyy-MM-dd hh:mm:ss');
            this.listQuery.date = [startDate,endDate];
            this.getList();
            this.getUserOptionList();
            this.gettakeCount();
        },
        filters: {
            formatCreateTime(time) {
                if(time){
                    let date = new Date(time);
                    return formatDate(date, 'yyyy-MM-dd hh:mm:ss')
                }else{
                    return '--'
                }
            },
            shipType(val,takeNum){
                if(parseFloat(val) == 0){
                    return '未发货'
                }else if(parseFloat(val) < parseFloat(takeNum)){
                    return '部分发货'
                }else{
                    return '已发货'
                }
            },
            fifState(val){
              if(val == 0){
                return '待物流发货'
              }else if(val == 10){
                return '发货中'
              }else if(val == 20){
                return '待安排司机'
              }else if(val == 30){
                return '待出库'
              }else if(val == 40){
                return '已出库'
              }
            },
        },
        methods:{
          gettakeCount(){
            takeCount().then((res)=>{
              this.waitNum = res.takeCount;
            })
          },
          topurchasePickUp(){
            this.$router.push({name:'purchasePickUp'})
          },
            //去排货详情页
            toInfo(item){
              let routeData = this.$router.resolve({name:'dischargingInfo',query:{dpgId:item.dpgId}});
              window.open(routeData.href);
            },
            //物流发货
            showSendGoods(item){
              this.$refs.sendGoods.showPop(item)
            },

            //显示货源
            showHoYuan(item){
                this.$refs.sourceGoods.showPop(item,'0')
            },

            //判断是否能选择
            checkSelectable(row,index){
                let flag = true;
                for (let i = 0; i < this.sendList.length; i++) {
                    if( parseFloat(row.unPlanNum) == 0){
                        flag = false
                    }
                }
                return flag
            },

            //显示确认发货弹窗
            showDialogVisible(item){
                this.dialogVisible2 = true;
                this.selectList = [];
                this.chooseUnPlanNum = 0;
                this.PlanNum = item.unShipNum;
                this.dpgId = item.dpgId;
                this.getChooseList(item);
            },

            //关闭确认发货弹窗
            handleClose2(){
                this.$refs.multipleTable.clearSelection();
                this.dialogVisible2 = false;
            },

            /**
             *获取选择发货单列表
             **/
            getChooseList(item) {
                this.listLoading2 = true;
                getDeliverGoods({ogId:item.ogId}).then(response => {
                    this.listLoading2 = false;
                    this.sendList = response;
                });
            },

            //切换选择发货单
            handleSelectionChange(val){
                this.selectList = JSON.parse(JSON.stringify(val));
                this.countUnPlanNum();
            },

            //计算已选中发货单的未核减数量
            countUnPlanNum(){
                this.chooseUnPlanNum = 0
                this.selectList.forEach((el)=>{
                    this.chooseUnPlanNum = this.chooseUnPlanNum + parseFloat(el.unPlanNum)
                });
                this.chooseUnPlanNum = this.chooseUnPlanNum.toFixed(4)
            },

            //提交确认的发货单
            handleConfirm2(){
                if(this.selectList.length > 0){
                    let data = {};
                    data.dpgId = this.dpgId;
                    data.dgIds = [];
                    this.selectList.forEach((el)=>{
                        data.dgIds.push(el.dgId)
                    });
                    this.handleClose2();
                    planGoodsOperate(data).then(response=>{
                        this.$message({
                            message: '操作成功',
                            type: 'success',
                            duration:1000
                        });
                        this.getList();
                    });
                }else{
                    this.$message({
                        message: '请选择要核减的发货单',
                        type: 'info',
                        duration:1000
                    });
                }
            },

            //显示提货信息
            showDialog3(item){
                this.dialogVisible3 = true;
                this.priceForm = JSON.parse(JSON.stringify(defaultPriceForm));
                this.priceForm.goodsName = item.goodsName + '/' + item.goodsSn;
                this.priceForm.warehouseName = item.warehouseName;
                this.priceForm.takeTime = item.takeTime;
                this.priceForm.takeNum = item.takeNum;
                this.priceForm.takeAddress = item.takeAddress;
                this.priceForm.contactName = item.contactName;
                this.priceForm.contactMobile = item.contactMobile;
                this.priceForm.takeRemark = item.takeRemark;
            },

            //获取员工下拉选项
            getUserOptionList(){
                getOrderUsersList().then((res)=>{
                    this.userOptionList = res;
                })
            },

            //选择员工名称
            handleSelectUserName(key,item){
                this.listQuery[key] = item.userId;
            },


            //客户名称输入匹配
            querySearch(queryString, cb){
                getCustomerOption({keywords:queryString}).then((res)=>{
                    cb(res);
                })
            },


            //选择客户名称
            handleSelectCustomerName(item){
                this.listQuery.customerName = item.customerName
            },

            /**
             * 切换选择状态
             */
            handleSelect(key, keyPath){
              if(key == 50){
                this.$router.push({name:'pickUpList',query:{tab:'wlqr'}})
              }else if(key == 60){
                this.$router.push({name:'pickUpList',query:{tab:'all'}})
              }else{
                  this.listQuery = JSON.parse(JSON.stringify(defaultListQuery));
                  this.listQuery.planState = key;
                  this.handleSearchList();
              }

            },
            handleSizeChange(val){
                this.listQuery.pageNum = 1;
                this.listQuery.pageSize = val;
                this.getList();
            },
            handleCurrentChange(val){
                this.listQuery.pageNum = val;
                this.getList();
            },

            handleSearchList(){
                this.listQuery.pageNum = 1;
                this.getList();
            },

            //获取列表
            getList() {
                this.listLoading = true;
                getPlanGoodsList(this.listQuery).then(response => {
                    this.tableData = response.list;
                    this.count = response.count;
                    this.listLoading = false;
                }).catch(()=>{
                    this.listLoading = false;
                });
            },

        },
    }
</script>


